package com.mapper;

import com.pojo.Users;
import org.apache.catalina.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UsersMapper {

    @Select("select * from users where contact = #{value}")
    Users findByNumber(String contact);

    // 插入数据 调用pojo包users.xml里的insertUsers配置 返回值0(失败),1(成功)
    //@Insert("insert into users(usersid , username , password , realname , sex , birthday , contact , regdate ) values(#{usersid} , #{username} , #{password} , #{realname} , #{sex} , #{birthday} , #{contact} , #{regdate} )")
    public int insertUsers(Users users);

    // 更新数据 调用pojo包users.xml里的updateUsers配置 返回值0(失败),1(成功)
   // @Update("update users set username=#{username} , password=#{password} , realname=#{realname} , sex=#{sex} , birthday=#{birthday} , contact=#{contact} , regdate=#{regdate} where usersid=#{usersid}")
    public int updateUsers(Users users);

    // 删除数据 调用pojo包users.xml里的deleteUsers配置 返回值0(失败),1(成功)
   // @Delete("delete from users where usersid = #{usersid}")
    public int deleteUsers(String usersid);

    // 查询全部数据 调用pojo包users.xml里的getAllUsers配置 返回List类型的数据
    //@Select("select a.* from users a where 1=1 order by usersid desc")
    public List<Users> getAllUsers();

    // 按照Users类里面的值精确查询 调用pojo包users.xml里的getUsersByCond配置 返回List类型的数据
    //@Select("select a.* from users a where 1=1")
    public List<Users> getUsersByCond(Users users);

    // 按照Users类里面的值模糊查询 调用pojo包users.xml里的getUsersByLike配置 返回List类型的数据
   // @Select("select a.* from users a where 1=1")
    public List<Users> getUsersByLike(Users users);

    // 按主键查询表返回单一的Users实例 调用pojo包users.xml里的getUsersById配置
   // @Select("select a.* from users a where 1=1 and usersid=#{usersid} order by usersid desc")
    public Users getUsersById(String usersid);
//    @Select("select * from users")
//    List<Users> findAll();
}
